import React from 'react';
import {Badge, Icon, List, Popover} from 'antd';

const AlertInfo = props => {
    const {item = [], containerOrderExpiredList = [], noticeList = [], contractExpireList = []} = props;
    const dataList = [];
    containerOrderExpiredList.forEach(item => {
        dataList.push({'data': item, "type": "containerOrderExpiredList"});
    });
    noticeList.forEach(item => {
        dataList.push({'data': item, "type": "noticeList"});
    });
    contractExpireList.forEach(item => {
        dataList.push({'data': item, "type": "contractExpireList"});
    });
    const content = (<List
        size="small"
        header={null}
        footer={null}
        bordered={false}
        dataSource={dataList}
        renderItem={item => item.type === "containerOrderExpiredList" ?
            <List.Item>{item.data}</List.Item> : item.type === "noticeList" ?
                <List.Item>{" 系统通知 标题：" + item.data.title + " 公告有效期：" + item.data.startTime + " 至 " + item.data.endTime}</List.Item> : item.type === "contractExpireList" ?
                    <List.Item>{item.data}</List.Item> : null}
    />);
    return (
        <Popover placement="bottom" content={content}>
            <Badge count={dataList.length}>
                <Icon type="notification"/>
            </Badge>
        </Popover>
    );
};

export default AlertInfo;
